function MyDictionary() {
  this.Add = mAdd;
  this.Lookup = mLookup;
  this.Delete = mDelete
}
function mLookup(strKeyName)
{
    return(this[strKeyName]);
}
function mAdd()
{
    for (c=0; c < mAdd.arguments.length; c+=2) {
      this[mAdd.arguments[c]] = mAdd.arguments[c+1];
    }
}
function mDelete(strKeyName)
{
    for (c=0; c < mDelete.arguments.length; c++) {
      this[mDelete.arguments[c]] = null;
    }
}
function ajaxRequest(url_to, call_back_func, is_assynch, args)
{
    this.request = null;
    this.onReadyStateFunc = call_back_func;
    this.params = null;
    this.urlTo = url_to;
    this.isAssynch = is_assynch;
    this.arguments = arguments;
    this.args = args;
    this.callbackArguments = null;
    this.initParams = function()
    {
        this.params = new Array();
        for (i = 4; i < this.arguments.length; i++)
        {
            this.params[i - 4] = this.arguments[i];
        }
        if (args == null)
            return;
        this.callbackArguments = new MyDictionary();
        for (i = 0; i < this.args.length; i++)
        {
            var pieces = this.args[i].split("=");
            this.callbackArguments.Add(pieces[0], pieces[1]);
        }    
    };
    this.createRequest = function()
    {
        try 
        {
            this.request = new XMLHttpRequest();
        } 
        catch (trymicrosoft)
        {
            try
            {
                this.request = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (othermicrosoft)
            {
                try
                {
                    this.request = new ActiveXObject("Microsoft.XMLHTTP");
                } 
                catch (failed)
                {
                    this.request = false;
                }
            }
        }
        if (! this.request)
            outputMessages("Error initializing XMLHttpRequest!");
    };
    this.sendAjaxPost = function()
    {
        this.request.open("POST", this.urlTo, this.isAssynch);
        this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
        this.request.setRequestHeader("Accept-Language", "ch, ru, en");
        var self = this;
        this.request.onreadystatechange = function()
        {
            if (self.request.readyState == 4)
            {
                if (self.request.status == 200)
                {                 
                    if (self.request.responseText != ''){
                        var responseObj = eval('(' + self.request.responseText + ')');
                        if (responseObj.req_status == undefined)
                        {
                            responseObj.req_status = -1;
                            self.onReadyStateFunc(responseObj, self.callbackArguments);
                        }
                        else
                            self.onReadyStateFunc(responseObj, self.callbackArguments);
                    }
                    else
                    {
                        alert("Response is empty");
                    }
                }
                else
                {
                    alert("Response status is" + self.request.status);
                }
            }
        }
        toSend = "ajax=1";
        for (i = 0; i < this.params.length; i++)
        {
            toSend += "&" + this.params[i];
        }        
        this.request.send(toSend);
    };
    this.initParams();
    this.createRequest();
    this.sendAjaxPost();
}